struct Solution {}

fn main() {}

impl Solution {
    pub fn count_prime_set_bits(left: i32, right: i32) -> i32 {
        let mut ret = 0;
        for num in left..=right {
            if Self::check(num) {
                ret += 1;
            }
        }
        ret
    }

    fn check(n: i32) -> bool {
        let mut arr: Vec<i32> = Self::get_bit_array(n);
        Self::is_prime_in_32(arr.iter().sum())
    }

    fn is_prime_in_32(n: i32) -> bool {
        let primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37];
        primes.contains(&n)
    }

    fn get_bit_array(n: i32) -> Vec<i32> {
        let mut res = vec![];
        let mut n_cp = n;
        while n_cp > 0 {
            res.push(n_cp % 2);
            n_cp = n_cp / 2;
        }
        res
    }
}